home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
money_maze.swf
/
scripts
/
DefineSprite_421
/
frame_1
/
DoAction.as
Wrap
Text File
|
2007-09-27
|
37KB
|
1,450 lines
function loadSoundFromLib(sName, sVolume)
{
MCCreated++;
var _loc2_ = createEmptyMovieClip("mc" + MCCreated,MCCreated);
var _loc1_ = new Sound(_loc2_);
_loc1_.attachSound(sName);
_loc1_.setVolume(sVolume);
return _loc1_;
}
function playSound(oSoundObj, iRepeat)
{
oSoundObj.start(0,Number(iRepeat));
}
function MazeClass(mc, sLinkID, iLevelFrame)
{
var _loc1_ = this;
_loc1_.rows = [];
_loc1_.objects = [];
_loc1_.allFlags = [];
_loc1_.displayList = [];
_loc1_.doors = [];
_loc1_.target = mc;
_loc1_.level = mc.attachMovie(sLinkID,"mcLevel",10);
_loc1_.level.gotoAndStop(iLevelFrame + 5);
_loc1_.level.mc._visible = false;
_loc1_.viewPort = new _loc1_.ViewPortClass(_loc1_,ScreenWidth,ScreenHeight);
}
function OpponentClass(sChar)
{
var _loc1_ = this;
_loc1_.speed = 150;
_loc1_.width = 50;
_loc1_.height = 60;
_loc1_.state = 0;
_loc1_.linkageID = sChar;
_loc1_.canBeTrapped = true;
_loc1_.keyUp = _loc1_.keyDown = false;
}
function MainCharClass()
{
var _loc1_ = this;
_loc1_.speed = 300;
_loc1_.width = 50;
_loc1_.height = 60;
_loc1_.state = 0;
_loc1_.canUseSafe = true;
_loc1_.canCollectTokens = true;
}
function createObject(oGame, mc)
{
var _loc1_ = mc;
var _loc2_ = oGame;
_loc1_._visible = false;
switch(_loc1_.type)
{
case "floor":
return null;
case "wall":
_loc2_.addWall(_loc1_._x,_loc1_._y);
break;
case "stairs":
var o = {x:_loc1_._x + 1,y:0};
_loc1_.localToGlobal(o);
var _loc3_ = o.x;
var o = {x:_loc1_._x,y:0};
_loc2_.addStairs(_loc1_._x,_loc1_._y,_loc1_.mc._rotation + 90,_loc3_ < o.x);
break;
case "safe":
_loc2_.addSafe(_loc1_);
break;
case "spawnpoint":
_loc2_.addSpawnPoint(_loc1_._x,_loc1_._y);
break;
case "door":
_loc1_._visible = true;
_loc2_.addDoor(_loc1_);
break;
case "trap":
_loc2_.addTrap(_loc1_);
break;
default:
_loc1_._visible = true;
}
}
function checkTrap(oFlag)
{
var _loc1_ = oFlag;
var _loc2_ = this;
if(!_loc2_.canBeTrapped || !_loc1_.active)
{
return null;
}
_loc2_.trapped = _loc1_;
mcInterface.setCaught(true);
_loc1_.mc.gotoAndPlay("catch");
_loc1_.active = false;
_loc2_.wait = 3;
}
function collectRemote(oFlag)
{
var _loc1_ = oFlag;
if(this.canCollectTokens && !_loc1_.disabled && this.layer == 0)
{
_loc1_.disabled = true;
_loc1_.target._visible = false;
setTrapState(true,10000);
}
}
function collectToken(oFlag)
{
var _loc1_ = oFlag;
if(this.canCollectTokens && _loc1_.target._visible == true && this.layer == 0)
{
tokensRemaining--;
tokensCollected++;
_loc1_.disabled = true;
_loc1_.target._visible = false;
onTokenCollected(_loc1_.value);
}
}
function checkIfInDoor(oFlag)
{
var _loc1_ = oFlag;
var _loc2_ = this;
if(Math.abs(_loc1_.mc._x - _loc2_.x) < _loc1_.hWidth)
{
_loc2_.currentDoor = _loc1_.mc;
}
else
{
_loc2_.currentDoor = null;
}
}
function enterSafe(oFlag)
{
this.currentSafe = oFlag.mc;
}
function exitSafe(oFlag)
{
this.currentSafe = null;
}
function useSafe(o, oFlag)
{
if(tokensCollected <= 0)
{
return 0;
}
__totalBank = tokensBanked + tokensCollected;
var _loc1_ = new CallStackClass(gameUpdateInterval);
_loc1_.append(playMovieClip,oFlag.mcSafe,"open");
_loc1_.append(depositMoney,Math.ceil(tokensCollected * 0.01));
_loc1_.append(setObjectProp,o,"state",0);
_loc1_.start();
o.state = 1;
}
function depositMoney(iPerStep)
{
var _loc1_ = Math.min(tokensCollected,iPerStep);
tokensBanked += _loc1_;
tokensCollected -= _loc1_;
onDepositCash(iPerStep);
updateInterface();
if(tokensCollected > 0)
{
return false;
}
tokensCollected = 0;
tokensBanked = __totalBank;
return true;
}
function setTrapState(bActive, iMsTime)
{
var _loc2_ = bActive;
var _loc3_ = iMsTime;
var _loc1_ = 0;
while(_loc1_ < Game.traps.length)
{
Game.traps[_loc1_].active = _loc2_;
Game.traps[_loc1_].mc.gotoAndStop(!_loc2_ ? "off" : "on");
if(_loc2_)
{
TrapTimeRemaining = _loc3_;
}
else
{
TrapTimeRemaining = 0;
}
CollectedMoney = !_loc2_;
_loc1_ = _loc1_ + 1;
}
mcInterface.setTrapsActive(_loc2_);
}
function alignRightOfFlag(oFlag)
{
var _loc1_ = this;
_loc1_.moveTo(oFlag.x + _loc1_.halfWidth + 0.01,_loc1_.y);
}
function alignLeftOfFlag(oFlag)
{
var _loc1_ = this;
_loc1_.moveTo(oFlag.x - _loc1_.halfWidth - 0.01,_loc1_.y);
}
function goUpStairs(oFlag)
{
var _loc1_ = this;
if(_loc1_.vDir <= 0)
{
return null;
}
orientToFlag(_loc1_,oFlag);
_loc1_.setLayer(1);
}
function goDownStairs(oFlag)
{
var _loc1_ = this;
if(_loc1_.vDir >= 0)
{
return null;
}
orientToFlag(_loc1_,oFlag);
_loc1_.setLayer(1);
}
function getOffStairs(oFlag)
{
var _loc1_ = this;
_loc1_.upX = 0;
_loc1_.upY = 1;
_loc1_.rightX = 1;
_loc1_.rightY = 0;
_loc1_.setLayer(0);
_loc1_.moveTo(_loc1_.x,oFlag.y);
}
function orientToFlag(oRef, oFlag)
{
var _loc1_ = oRef;
var _loc2_ = oFlag;
_loc1_.upX = _loc2_.upX;
_loc1_.upY = _loc2_.upY;
_loc1_.rightX = _loc2_.rightX;
_loc1_.rightY = _loc2_.rightY;
var _loc3_ = _loc1_.x - _loc2_.x;
_loc1_.x = _loc2_.x;
_loc1_.y = _loc2_.y;
_loc1_.moveBy(_loc3_ * _loc1_.rightX,_loc3_ * _loc1_.rightY);
}
function isBetween(iNum, i0, i1)
{
var _loc1_ = iNum;
var _loc2_ = i1;
var _loc3_ = i0;
if(_loc3_ < _loc2_)
{
§§push(_loc1_ >= _loc3_);
if(_loc1_ >= _loc3_)
{
§§pop();
return _loc1_ < _loc2_;
}
}
§§push(_loc1_ > _loc2_);
if(_loc1_ > _loc2_)
{
§§pop();
return _loc1_ <= _loc3_;
}
}
function goThruDoor(o, oDoor)
{
var _loc3_ = undefined;
var _loc1_ = 0;
while(_loc1_ < Game.doors.length)
{
_loc3_ = Game.doors[_loc1_];
if(_loc3_.id == oDoor.id && oDoor != _loc3_)
{
var targetDoor = o.currentDoor = Game.doors[_loc1_];
break;
}
_loc1_ = _loc1_ + 1;
}
var T;
var _loc2_ = new CallStackClass(gameUpdateInterval);
_loc2_.append(playMovieClip,oDoor.mcDoor,"open");
_loc2_.append(_loc2_.wait,300);
T = addTweenToStack(_loc2_).createNewTween(o.target);
T.addPosition(0.1,oDoor._x,oDoor._y);
T = addTweenToStack(_loc2_).createNewTween(o.target);
T.addOffsetTint(0.1,0,0,0,0,-255,-255,-255,-255);
_loc2_.append(playMovieClip,oDoor.mcDoor,"close");
_loc2_.append(_loc2_.wait,150);
_loc2_.append(moveObject,o,targetDoor._x,targetDoor._y);
_loc2_.append(_loc2_.wait,100);
_loc2_.append(playMovieClip,targetDoor.mcDoor,"open");
_loc2_.append(_loc2_.wait,500);
T = addTweenToStack(_loc2_).createNewTween(o.target);
T.addOffsetTint(0.1,-255,-255,-255,-255,0,0,0,0);
_loc2_.append(setObjectProp,o,"state",0);
_loc2_.append(playMovieClip,targetDoor.mcDoor,"close");
_loc2_.start();
o.state = 1;
}
function playMovieClip(mc, sFrame)
{
mc.gotoAndPlay(sFrame);
}
function moveObject(o, iX, iY)
{
o.moveTo(iX,iY);
}
function setObjectProp(o, sProp, vValue)
{
o[sProp] = vValue;
}
function waitForElements()
{
if(Game.prep == null)
{
return false;
}
Game.setupElements();
return true;
}
function gotoLevel(iLevel)
{
Game.mcLevel._visible = false;
currentLevel = iLevel;
var _loc1_ = new CallStackClass(32);
if(Game != null)
{
_loc1_.append(removeCurrentGame);
}
_loc1_.append(createNewMaze,iLevel);
_loc1_.append(waitForElements);
_loc1_.append(setupLevel);
_loc1_.append(beginGame);
_loc1_.start();
}
function createNewMaze(iLevel)
{
var _loc1_ = createEmptyMovieClip("mcStage",0);
Game = new MazeClass(_loc1_,"levels",iLevel);
tokensCollected = 0;
tokensBanked = 0;
}
function beginGame()
{
updateInterface();
if(MovieClip.prototype._gameIntervalID != null)
{
clearInterval(MovieClip.prototype._gameIntervalID);
}
MovieClip.prototype._gameIntervalID = setInterval(updateGame,gameUpdateInterval);
Game.level.mc._visible = true;
lastTime = getTimer() * 0.001;
active = true;
unpause();
MainChar.moveCharacter(0.01,false,false,true,false);
updateGame();
}
function updateGame()
{
var _loc1_ = Math.min(0.04,- lastTime + (lastTime = getTimer() * 0.001));
if(paused || !active)
{
return null;
}
checkTraps(_loc1_);
Game.step(_loc1_,2);
updateAfterEvent();
}
function checkTraps(elapsed)
{
if(TrapTimeRemaining <= 0)
{
return null;
}
TrapTimeRemaining -= elapsed;
if(TrapTimeRemaining <= 0)
{
setTrapState(false);
}
}
function endGame()
{
}
function setupLevel()
{
var _loc1_ = undefined;
var _loc0_ = null;
var _loc2_ = mainChar = Game.createObject(MainCharClass);
_loc2_.alignTo(Game.entryPoint[0]);
Game.Viewport.addWatch(_loc2_);
switch(currentLevel % 3)
{
case 0:
_loc1_ = "charRaven";
break;
case 1:
_loc1_ = "charMom";
break;
case 2:
_loc1_ = "charDad";
}
_loc2_ = Game.createObject(OpponentClass,_loc1_);
_loc2_.alignTo(Game.entryPoint[1]);
CreateTokens("_ITEM_COIN");
i = 0;
while(i < Game.rows.length)
{
Game.rows[i].flags.bubbleSortOn("x");
i++;
}
setTrapState(false);
}
function pause()
{
if(active)
{
paused = true;
}
}
function unpause()
{
paused = false;
}
function loseLife()
{
lives--;
pause();
if(lives <= 0)
{
_root.gotoAndStop("GameLose");
}
else
{
mcInterface.mcDialog.showDialog("loseLife");
updateInterface();
}
}
function createTokens(sIdentifier)
{
var a;
var r;
var _loc2_ = undefined;
var tokens;
var xSpace;
var xSpan;
var _loc3_ = undefined;
var _loc1_ = undefined;
var remoteUsed;
tokensRemaining = 0;
var i = 0;
while(i < Game.rows.length)
{
remoteUsed = false;
r = Game.rows[i];
a = r.flags;
_loc2_ = [];
_loc1_ = 0;
while(_loc1_ < a.length)
{
_loc2_.push(a[_loc1_].x);
_loc1_ = _loc1_ + 1;
}
_loc2_.sortNumbers();
xSpan = _loc2_[_loc2_.length - 1] - _loc2_[0];
tokens = Math.floor(xSpan / tokenWidth);
xSpace = xSpan / tokens;
_loc3_ = _loc2_[0];
_loc1_ = 0;
while(_loc1_ < tokens - 1)
{
_loc3_ += xSpace;
if(!remoteUsed && random(tokens - 4) == 0)
{
Game.addRemote(_loc3_,r.y,"remote");
remoteUsed = true;
}
else
{
tokensTotal = tokensRemaining++;
Game.addToken(_loc3_,r.y,sIdentifier,Number(random(4) == 0));
}
_loc1_ = _loc1_ + 1;
}
i++;
}
trace(tokensTotal);
}
function startNewGame()
{
lives = 3;
mcInterface.setScore(0);
gotoLevel(1);
}
function addBonus(iAmmount)
{
bonusAmmount += iAmmount;
playSound(sndBank);
mcInterface.appendScore(iAmmount);
mcInterface.mcDialog.bonusAmmount = "$" + bonusAmmount;
}
function endLevel()
{
bonusAmmount = 0;
mcInterface.mcDialog.bonusAmmount = "$0";
active = false;
var _loc1_ = new CallStackClass(10);
_loc1_.append(mcInterface.mcDialog.showDialog,"bonus");
_loc1_.append(_loc1_.wait,1000);
if(lives >= 1)
{
_loc1_.append(addBonus,1000);
_loc1_.append(_loc1_.wait,300);
}
if(lives >= 2)
{
_loc1_.append(addBonus,4000);
_loc1_.append(_loc1_.wait,300);
}
if(lives >= 3)
{
_loc1_.append(addBonus,5000);
_loc1_.append(_loc1_.wait,300);
}
_loc1_.append(_loc1_.wait,700);
if(currentLevel == 3)
{
_loc1_.append(setTimeOut,gotoEnd,100);
}
else
{
_loc1_.append(mcInterface.mcDialog.showDialog,"endLevel");
_loc1_.append(endGame);
}
_loc1_.start();
}
function gotoEnd()
{
_root.gotoAndStop("gameWin");
}
function gotoNextLevel()
{
currentLevel++;
if(currentLevel > 3)
{
_root.gotoAndStop("gameWin");
}
else
{
gotoLevel(currentLevel);
}
}
function onTokenCollected(iValue)
{
playSound(sndCollectCash,0);
mcInterface.appendScore(iValue * 50 + 50);
}
function onDepositCash(fNumber)
{
mcInterface.appendScore(50 * fNumber);
if(tokensCollected == 0 && tokensBanked >= tokensTotal)
{
endLevel();
}
}
function onCollision(oA, oB)
{
var _loc1_ = oB;
var _loc2_ = oA;
if(!_loc1_.trapped && !_loc2_.trapped)
{
_loc2_.alignTo(Game.entryPoint[0]);
_loc1_.alignTo(Game.entryPoint[1]);
_loc2_.resetVector();
_loc1_.resetVector();
_loc2_.layer = _loc1_.layer = 0;
pause();
loseLife();
}
else
{
if(CollectedMoney)
{
return null;
}
playSound(sndBank,0);
mcInterface.appendScore(5000);
CollectedMoney = true;
}
}
function onObjectsUpdate(oGame)
{
var _loc3_ = oGame;
var _loc1_ = undefined;
var _loc2_ = 1;
while(_loc2_ < _loc3_.objects.length)
{
_loc1_ = _loc3_.objects[_loc2_];
if(!(MainChar.row != _loc1_.row || MainChar.state == 1 || _loc1_.state == 1))
{
if(MainChar.layer == _loc1_.layer)
{
if(!(Math.abs(MainChar.x - _loc1_.x) > MainChar.halfWidth || Math.abs(MainChar.y - _loc1_.y) > 20))
{
onCollision(MainChar,_loc1_);
break;
}
}
}
_loc2_ = _loc2_ + 1;
}
}
function updateInterface()
{
var _loc1_ = int(tokensCollected);
var _loc2_ = int(tokensBanked);
if(_loc1_ != mcInterface.tokensCollected)
{
mcInterface.tokensCollected = _loc1_;
}
if(_loc2_ != mcInterface.tokensBanked)
{
mcInterface.tokensBanked = _loc2_;
}
if(lives != 0)
{
mcInterface.mcLives.gotoAndStop(lives);
}
}
mcInterface.swapDepths(10000);
rowAdjust = 20;
gameUpdateInterval = 10;
active = false;
ScreenWidth = 595;
ScreenHeight = 440;
tokenWidth = 40;
currentLevel = 1;
wallThickness = 10;
paused = false;
FLAG_AXIS = 1;
FLAG_BOUNDS = 2;
FLAG_LEFT_BOUNDS = 3;
FLAG_RIGHT_BOUNDS = 4;
MovieClip.prototype.registerElement = function(sType, mc)
{
Game.elementToPrep(sType,mc);
};
MovieClip.prototype.drawLine = function(sX, sY, eX, eY)
{
moveTo(sX,sY);
lineStyle(1,0,100);
lineTo(eX,eY);
};
sndCollectCash = loadSoundFromLib("CollectMoney",50);
sndBank = loadSoundFromLib("Money",500);
MCP = MazeClass.prototype;
MCP.ViewPortClass = function(oWorld, iWidth, iHeight)
{
var _loc1_ = this;
var _loc2_ = oWorld;
_loc1_.width = iWidth;
_loc1_.height = iHeight;
var hWidth = _loc1_.hWidth = iWidth * 0.5;
var _loc0_ = null;
var _loc3_ = _loc1_.hHieght = iHeight * 0.5;
_loc1_.levelWidth = _loc2_.target._width - _loc3_ * 0.25;
_loc1_.levelHeight = _loc2_.target._height;
_loc1_.world = _loc2_;
_loc1_.watch = [];
};
VCP = MCP.ViewPortClass.prototype;
VCP.addWatch = function(oRef)
{
if(this.watch.indexOf(oRef) == -1)
{
this.watch.push(oRef);
}
};
VCP.removeWatch = function(oRef)
{
this.watch.remove(oRef);
};
VCP.update = function()
{
var _loc3_ = this;
var _loc1_ = undefined;
if(_loc3_.watch.length == 1)
{
_loc1_ = _loc3_.watch[0];
_loc3_.x = _loc1_.x;
_loc3_.y = _loc1_.y;
}
else
{
var L = oWorld.target._width;
var R = 0;
var T = oWorld.target._height;
var B = 0;
var _loc2_ = 0;
while(_loc2_ < _loc3_.watch.length)
{
_loc1_ = _loc3_.watch[_loc2_];
L = Math.min(L,_loc1_.x);
R = Math.max(R,_loc1_.x);
T = Math.min(T,_loc1_.y);
B = Math.max(B,_loc1_.y);
_loc2_ = _loc2_ + 1;
}
}
var xspan = - (_loc3_.x - _loc3_.hWidth) - _loc3_.world.target._x;
var xDir = xspan <= 0 ? -1 : 1;
if(Math.abs(xspan) > _loc3_.hwidth * 0.4)
{
var x = - _loc3_.x + xDir * _loc3_.hWidth * 0.3;
x = - Math.min(Math.max(_loc3_.hWidth,- x),_loc3_.levelWidth) + _loc3_.hWidth;
if(_loc3_.world.target._x != x)
{
_loc3_.world.target._x = x;
}
}
};
MCP.RowClass = function(iY)
{
this.y = iY;
this.flags = [];
};
RCP = MCP.RowClass.prototype;
RCP.addFlag = function(o)
{
this.flags.push(o);
};
MCP.FlagClass = function(iType, iX, iY, fnLtR, fnRtL)
{
var _loc1_ = this;
_loc1_.x = iX;
_loc1_.y = iY;
_loc1_.disabled = false;
_loc1_.type = iType;
_loc1_.leftToRight = fnLtR;
_loc1_.rightToLeft = fnRtL;
};
MCP.findRowNumber = function(iY)
{
var _loc2_ = this;
var _loc3_ = iY;
var _loc1_ = 0;
while(_loc1_ < _loc2_.rows.length)
{
if(_loc3_ < _loc2_.rows[_loc1_].y + RowAdjust)
{
return _loc1_;
}
_loc1_ = _loc1_ + 1;
}
return 0;
};
MCP.elementToPrep = function(sType, mc)
{
var _loc1_ = this;
var _loc2_ = mc;
var _loc3_ = sType;
if(_loc1_.prep == null)
{
_loc1_.prep = {};
_loc1_.prep.all = [];
}
_loc2_.type = _loc3_.toLowerCase();
if(_loc1_.prep[_loc3_] == null)
{
_loc1_.prep[_loc3_] = [_loc2_];
}
else
{
_loc1_.prep[_loc3_].push(_loc2_);
}
_loc1_.prep.all.push(_loc2_);
};
MCP.createFlag = function(iType, iX, iY, fnLtR, fnRtL, sName)
{
var _loc3_ = this;
var _loc2_ = _loc3_.findRowNumber(iY);
var _loc1_ = new _loc3_.FlagClass(iType,iX,_loc3_.rows[_loc2_].y,fnLtR,fnRtL);
_loc3_.rows[_loc2_].addFlag(_loc1_);
_loc1_.name = sName;
return _loc1_;
};
MCP.createObject = function(cn)
{
var _loc1_ = arguments;
var _loc2_ = new cn(_loc1_[1],_loc1_[2],_loc1_[3],_loc1_[4]);
this.objects.push(_loc2_);
_loc2_.init(this);
return _loc2_;
};
MCP.createRow = function(iY)
{
var _loc1_ = new this.RowClass(iY);
this.rows.push(_loc1_);
};
MCP.setupElements = function()
{
var _loc2_ = this;
var _loc3_ = _loc2_.prep.floor;
var _loc1_ = 0;
while(_loc1_ < _loc3_.length)
{
_loc2_.createRow(_loc3_[_loc1_]._y);
_loc1_ = _loc1_ + 1;
}
_loc2_.rows.sortOn("y");
var mc;
_loc3_ = _loc2_.prep.all;
_loc1_ = 0;
while(_loc1_ < _loc3_.length)
{
createObject(_loc2_,_loc3_[_loc1_]);
_loc1_ = _loc1_ + 1;
}
var rooms = _loc2_.rooms = [];
_loc1_ = 0;
while(_loc1_ < _loc2_.rows.length)
{
_loc2_.rows[_loc1_].flags.bubbleSortOn("x");
_loc2_.findRoomsOnRow(_loc1_);
_loc1_ = _loc1_ + 1;
}
};
MCP.findRoomsOnRow = function(iRow)
{
var _loc3_ = undefined;
var _loc1_ = undefined;
a = this.rows[iRow].flags;
var i = 0;
while(i < a.length - 1)
{
_loc3_ = a[i];
switch(_loc3_.name)
{
case "wallright":
_loc1_ = {};
_loc1_.branches = [];
_loc1_.left = _loc3_.x;
_loc1_.row = iRow;
break;
case "wallleft":
if(_loc1_ != null)
{
_loc1_.right = _loc3_.x;
var _loc2_ = 0;
while(_loc2_ < _loc1_.branches.length)
{
_loc1_.branches[_loc2_].room = _loc0_ = this.rooms.length;
_loc1_.branches[_loc2_].flag.room = _loc0_;
_loc2_ = _loc2_ + 1;
}
_loc1_.id = this.rooms.length;
this.rooms.push(_loc1_);
_loc1_ = null;
}
break;
case "door":
i++;
_loc1_.branches.push({flag:_loc3_,type:_loc3_.name,x:_loc3_.mc._x,row:iRow,id:_loc3_.id});
break;
case "stairsup":
case "stairsdown":
_loc1_.branches.push({flag:_loc3_,type:_loc3_.name,x:_loc3_.x,row:iRow});
break;
}
i++;
}
};
MCP.addSpawnPoint = function(iX, iY)
{
var _loc1_ = this;
var _loc3_ = _loc1_.findRowNumber(iY);
var _loc2_ = {x:iX,y:_loc1_.rows[_loc3_].y};
if(_loc1_.entryPoint == null)
{
_loc1_.entrypoint = [_loc2_];
}
else
{
_loc1_.entryPoint.push(_loc2_);
}
};
MCP.addToken = function(iX, iY, sLinkage, iFrame)
{
var _loc2_ = this.createFlag(FLAG_BOUNDS,iX,iY,collectToken,collectToken,"token");
var _loc0_ = null;
var _loc1_ = _loc2_.target = this.addMovieToLevel(sLinkage);
_loc1_._x = iX;
_loc1_._y = iY;
_loc1_.gotoAndStop(iFrame + 1);
_loc2_.value = iFrame;
};
MCP.addRemote = function(iX, iY, sLinkage)
{
var _loc2_ = this.createFlag(FLAG_BOUNDS,iX,iY,collectRemote,collectRemote,"remote");
var _loc0_ = null;
var _loc1_ = _loc2_.target = this.addMovieToLevel(sLinkage);
_loc1_._x = iX;
_loc1_._y = iY;
_loc1_.gotoAndStop(iFrame + 1);
_loc2_.value = iFrame;
};
MCP.addTrap = function(mc)
{
var _loc1_ = mc;
var _loc2_ = this;
_loc1_._visible = true;
var rowNum = _loc2_.findRowNumber(_loc1_._y);
var _loc3_ = _loc2_.createFlag(FLAG_AXIS,_loc1_._x,_loc1_._y,checkTrap,checkTrap,"trap");
_loc3_.mc = _loc1_;
if(_loc2_.traps == null)
{
_loc2_.traps = [];
}
_loc2_.traps.push(_loc3_);
};
MCP.addWall = function(iX, iY)
{
var _loc1_ = undefined;
_loc1_ = this.createFlag(FLAG_LEFT_BOUNDS,iX + wallThickness,iY,null,alignRightOfFlag,"wallright");
_loc1_ = this.createFlag(FLAG_RIGHT_BOUNDS,iX,iY,alignLeftOfFlag,null,"wallleft");
};
MCP.addDoor = function(mc)
{
var _loc2_ = mc;
var _loc3_ = this;
var rowNum = _loc3_.findRowNumber(_loc2_._y);
_loc2_._y = _loc3_.rows[rowNum];
var hWidth = _loc2_._width * 0.5;
var lFlag = _loc3_.createFlag(FLAG_AXIS,_loc2_._x - hWidth,_loc2_._y,checkIfInDoor,checkIfInDoor,"door");
var rFlag = _loc3_.createFlag(FLAG_AXIS,_loc2_._x + hWidth,_loc2_._y,checkIfInDoor,checkIfInDoor,"door");
rFlag.mc = lFlag.mc = _loc2_;
rFlag.mcDoor = lFlag.mcDoor = _loc2_.mcDoor;
rFlag.id = lFlag.id = _loc2_.id;
rFlag.hWidth = lFlag.hWidth = hWidth;
_loc2_.lFlag = lFlag;
_loc2_.rFlag = rFlag;
var _loc1_ = 0;
while(_loc1_ < _loc3_.doors.length)
{
if(_loc3_.doors[_loc1_].id == _loc2_.id)
{
_loc3_.doors[_loc1_].lFlag.other = _loc2_.lFlag;
_loc3_.doors[_loc1_].rFlag.other = _loc2_.rFlag;
_loc2_.lFlag.other = _loc3_.doors[_loc1_].lFlag;
_loc2_.rFlag.other = _loc3_.doors[_loc1_].rFlag;
}
_loc1_ = _loc1_ + 1;
}
_loc3_.doors.push(_loc2_);
};
MCP.addSafe = function(mc)
{
var _loc1_ = mc;
var _loc2_ = this;
var _loc3_ = _loc2_.findRowNumber(_loc1_._y);
_loc1_._y = _loc2_.rows[_loc3_].y;
_loc1_._visible = true;
var left = _loc2_.createFlag(FLAG_AXIS,_loc1_._x,_loc1_._y,enterSafe,exitSafe,"safe");
var right = _loc2_.createFlag(FLAG_AXIS,_loc1_._x + 50,_loc1_._y,exitSafe,enterSafe,"safe");
left.mc = right.mc = _loc1_;
};
MCP.addStairs = function(iX, iY, iAngle, bFlipped)
{
StairsCreated++;
var rowNum = this.findRowNumber(iY);
iY = this.rows[rowNum].y;
var fRad;
var vX;
var _loc3_ = undefined;
var upX;
var upY;
var rightX;
var rightY;
var topX;
var topY;
fRad = (iAngle - 180) / 180 * 3.1415;
vX = Math.sin(fRad);
_loc3_ = Math.cos(fRad);
upX = - _loc3_;
upY = vX;
var bLtR;
var bRtL;
var tLtR;
var tRtL;
if(bFlipped)
{
bRtL = goUpStairs;
tLtR = goDownStairs;
bLtR = tRtL = getOffStairs;
rightX = - upY;
rightY = upX;
}
else
{
bLtR = goUpStairs;
tRtL = goDownStairs;
bRtL = tLtR = getOffStairs;
rightX = - upY;
rightY = - upX;
bFlipped = -1;
}
var spanY = iY - this.rows[rowNum - 1].y;
var dist = Math.abs(1 / _loc3_) * spanY;
topX = iX + vX * bFlipped * dist;
topY = iY + _loc3_ * dist;
var _loc1_ = this.createFlag(FLAG_AXIS,iX,iY,bLtR,bRtL,"stairsup");
var _loc2_ = this.createFlag(FLAG_AXIS,topX,topY,tLtR,tRtL,"stairsdown");
_loc2_.flipped = _loc1_.flipped = bFlipped;
_loc2_.upX = _loc1_.upX = upX;
_loc2_.upY = _loc1_.upY = upY;
_loc2_.rightX = _loc1_.rightX = rightX;
_loc2_.rightY = _loc1_.rightY = rightY;
_loc2_.id = _loc1_.id = StairsCreated;
_loc2_.other = _loc1_;
_loc1_.other = _loc2_;
};
MCP.step = function(fStepSize, iCount)
{
var _loc2_ = iCount;
var _loc3_ = this;
_loc2_ = Math.max(_loc2_,1);
fStepSize /= _loc2_;
var _loc1_ = 0;
while(_loc1_ < _loc2_)
{
_loc3_.updateObjects(fStepSize);
_loc1_ = _loc1_ + 1;
}
_loc3_.updateDisplay();
_loc3_.viewport.update();
};
MCP.updateObjects = function(fStepSize)
{
var _loc2_ = this;
var _loc3_ = fStepSize;
var _loc1_ = 0;
while(_loc1_ < _loc2_.objects.length)
{
_loc2_.objects[_loc1_].update(_loc3_);
_loc1_ = _loc1_ + 1;
}
onObjectsUpdate(_loc2_);
};
MCP.addMovieToLevel = function(sLinkageID)
{
var _loc1_ = this;
_loc1_.movieClipsCreated = _loc1_.movieClipsCreated + 1;
var _loc2_ = _loc1_.target.mcLevel.attachMovie(sLinkageID,"mc" + _loc1_.movieClipsCreated,_loc1_.movieClipsCreated - 1000);
return _loc2_;
};
MCP.queueForDisplay = function(oRef)
{
var _loc1_ = oRef;
if(_loc1_.queued)
{
return null;
}
_loc1_.queued = true;
this.displayList.push(_loc1_);
};
MCP.updateDisplay = function()
{
var _loc2_ = this;
if(_loc2_.displayList.length == 0)
{
return null;
}
var _loc1_ = 0;
while(_loc1_ < _loc2_.displayList.length)
{
_loc2_.displayList[_loc1_].updateDisplay();
_loc2_.displayList[_loc1_].queued = false;
_loc1_ = _loc1_ + 1;
}
_loc2_.displayList = [];
};
MCP.GenericObject = function(sLinkageID)
{
var _loc1_ = this;
_loc1_.linkageID = sLinkageID;
_loc1_.upX = 0;
_loc1_.upY = 1;
_loc1_.rightX = 1;
_loc1_.rightY = 0;
_loc1_.setLayer(0);
};
GOP = MCP.GenericObject.prototype;
GOP.moveTo = function(iX, iY)
{
var _loc1_ = this;
var _loc2_ = _loc1_.x != (_loc1_.x = iX);
_loc2_ = _loc1_.y != (_loc1_.y = iY) || _loc2_;
if(!_loc2_)
{
return null;
}
_loc1_.level.queueForDisplay(_loc1_);
};
GOP.moveBy = function(iX, iY)
{
var _loc1_ = this;
_loc1_.moveTo(_loc1_.x + iX,_loc1_.y + iY);
};
GOP.alignTo = function(oRef)
{
this.moveTo(oRef.x,oRef.y);
};
GOP.init = function(oLevel)
{
var _loc1_ = this;
_loc1_.halfWidth = _loc1_.width * 0.5;
_loc1_.level = oLevel;
_loc1_.target = oLevel.addMovieToLevel(_loc1_.linkageID);
};
GOP.setLayer = function(iLevel)
{
this.layer = iLevel;
};
GOP.updateDisplay = function()
{
var _loc1_ = this;
mc = _loc1_.target;
mc._x = _loc1_.x;
mc._y = _loc1_.y;
};
GOP.getCurrentRoom = function(iX, iRow)
{
var _loc3_ = iX;
var _loc2_ = this.level.rooms;
var _loc1_ = 0;
while(_loc1_ < _loc2_.length)
{
if(_loc2_[_loc1_].row == iRow)
{
if(_loc3_ < _loc2_[_loc1_].right && _loc3_ > _loc2_[_loc1_].left)
{
return this.level.rooms[_loc1_];
}
}
_loc1_ = _loc1_ + 1;
}
};
GOP.findPath = function(iX, iRow)
{
var _loc1_ = this;
_loc1_.row = _loc1_.level.findRowNumber(_loc1_.y);
if(iRow == null)
{
return null;
}
var _loc2_ = _loc1_.getCurrentRoom(iX,iRow);
var _loc3_ = _loc1_.getCurrentRoom(_loc1_.x,_loc1_.row);
_root.path = _loc1_.path = _loc1_.testPathNode([],_loc3_,_loc2_,iX,_loc1_.x);
};
GOP.testPathNode = function(aRoomsUsed, oRoom, oTarget, iTarX, iLastX)
{
var _loc3_ = oRoom;
if(aRoomsUsed[_loc3_.id])
{
return null;
}
aRoomsUsed[_loc3_.id] = true;
var v;
var path;
var branch;
var _loc1_ = undefined;
var tmpX;
if(_loc3_.id == oTarget.id)
{
return [{room:_loc3_.id,x:iTarX}];
}
var _loc2_ = 0;
while(_loc2_ < _loc3_.branches.length)
{
branch = _loc3_.branches[_loc2_];
v = this.testPathNode(aRoomsUsed,this.level.rooms[branch.flag.other.room],oTarget,iTarX,branch.flag.x);
if(v != null)
{
_loc1_ = branch.flag;
v.unshift({room:_loc3_.id,x:(_loc1_.name != "door" ? _loc1_.x : _loc1_.mc._x),flag:_loc1_});
aRoomsUsed[_loc3_.id] = null;
return v;
}
_loc2_ = _loc2_ + 1;
}
aRoomsUsed[_loc3_.id] = null;
};
GOP.moveCharacter = function(fElapsed, bLeft, bUp, bRight, bDown)
{
var _loc2_ = this;
var oldX = _loc2_.x;
var oldY = _loc2_.y;
_loc2_.hDir = bRight - bLeft;
_loc2_.vDir = bUp - bDown;
if(_loc2_.hDir != 0)
{
_loc2_.fDir = _loc2_.hDir;
}
if(bUp)
{
if(_loc2_.currentDoor != null)
{
goThruDoor(_loc2_,_loc2_.currentDoor);
}
if(_loc2_.canUseSafe && _loc2_.currentSafe != null)
{
useSafe(_loc2_,_loc2_.currentSafe);
}
}
if(!_loc2_.walk(_loc2_.hDir,fElapsed))
{
return false;
}
var _loc1_ = undefined;
var aFlags = _loc2_.level.rows[_loc2_.row].flags;
var oLX;
var oRX;
var nLX;
var nRX;
oLX = oldX - _loc2_.halfWidth;
oRX = oldX + _loc2_.halfWidth;
nLX = _loc2_.x - _loc2_.halfWidth;
nRX = _loc2_.x + _loc2_.halfWidth;
var iLeft = Math.min(oLX,nLX);
var iRight = Math.max(oRX,nRX);
var _loc3_ = 0;
for(; _loc3_ < aFlags.length; _loc3_ = _loc3_ + 1)
{
_loc1_ = aFlags[_loc3_];
_loc2_.__tmpfnltr = _loc1_.leftToRight;
_loc2_.__tmpfnrtl = _loc1_.rightToLeft;
if(_loc1_.disabled)
{
continue;
}
if(_loc1_.x < iLeft)
{
continue;
}
if(_loc1_.x > iRight)
{
break;
}
switch(_loc1_.type)
{
case FLAG_AXIS:
if(isBetween(_loc1_.x,oldX,_loc2_.x))
{
if(_loc2_.hDir == 1)
{
_loc2_.__tmpfnltr(_loc1_);
}
else
{
_loc2_.__tmpfnrtl(_loc1_);
}
}
continue;
case FLAG_BOUNDS:
if(isBetween(_loc1_.x,oLX,nLX) || isBetween(_loc1_.x,oRX,nRX))
{
if(_loc2_.hDir == 1)
{
_loc2_.__tmpfnltr(_loc1_);
}
else
{
_loc2_.__tmpfnrtl(_loc1_);
}
}
continue;
case FLAG_LEFT_BOUNDS:
if(isBetween(_loc1_.x,oLX,nLX))
{
if(_loc2_.hDir == 1)
{
_loc2_.__tmpfnltr(_loc1_);
}
else
{
_loc2_.__tmpfnrtl(_loc1_);
}
}
continue;
case FLAG_RIGHT_BOUNDS:
if(isBetween(_loc1_.x,oRX,nRX))
{
if(_loc2_.hDir == 1)
{
_loc2_.__tmpfnltr(_loc1_);
}
else
{
_loc2_.__tmpfnrtl(_loc1_);
}
}
continue;
default:
continue;
}
}
};
GOP.walk = function(iDir, fElapsed)
{
var _loc1_ = this;
if(iDir == 0)
{
_loc1_.target.gotoAndStop(_loc1_.fDir != 1 ? "stand_l" : "stand_r");
return false;
}
var _loc2_ = iDir * fElapsed * _loc1_.speed;
_loc1_.moveBy(_loc2_ * _loc1_.rightX,_loc2_ * _loc1_.rightY);
_loc1_.target.gotoAndStop(_loc1_.fDir != 1 ? "walk_l" : "walk_r");
_loc1_.row = _loc1_.level.findRowNumber(_loc1_.y);
return true;
};
GOP.resetVector = function()
{
var _loc1_ = this;
_loc1_.upX = 0;
_loc1_.upY = 1;
_loc1_.rightX = 1;
_loc1_.rightY = 0;
};
OpponentClass.prototype = new MCP.GenericObject();
OCP = OpponentClass.prototype;
OCP.findNewPath = function(bNotChar)
{
var _loc1_ = undefined;
var _loc2_ = undefined;
var _loc3_ = undefined;
if(random(4) == 1 && MainChar.row != null && !bNotChar)
{
_loc3_ = MainChar.x;
_loc2_ = MainChar.row;
}
else
{
_loc1_ = this.level.rooms[random(this.level.rooms.length)];
_loc3_ = _loc1_.left + random(_loc1_.right - _loc1_.left - 200) + 100;
_loc2_ = _loc1_.row;
}
this.findPath(_loc3_,_loc2_);
};
OCP.update = function(fElapsed)
{
var _loc1_ = this;
var _loc3_ = fElapsed;
if(_loc1_.wait > 0)
{
TrapTimeRemaining = 0;
_loc1_.trapped = true;
_loc1_.wait -= _loc3_;
if(_loc1_.wait <= 0)
{
_loc1_.trapped = false;
_loc1_.trapped.mc.gotoAndPlay("release");
mcInterface.setCaught(false);
setTrapState(false);
}
return null;
}
if(_loc1_.state == 0 && MainChar.state == 0)
{
if(_loc1_.path.length == 0 || _loc1_.path == null)
{
_loc1_.findNewPath();
}
else
{
var _loc2_ = _loc1_.path[0];
var distX = Math.abs(_loc2_.x - _loc1_.x);
_loc1_.reaction += _loc3_;
if(_loc1_.layer == 0 && _loc1_.reaction > 0.1)
{
_loc1_.reaction = 0;
var sNext = _loc2_.flag.name;
_loc1_.reaction += _loc3_;
_loc1_.keyLeft = _loc2_.x < _loc1_.x;
_loc1_.keyRight = _loc2_.x > _loc1_.x;
var changed = _loc1_.zone != (_loc1_.zone = Math.floor(_loc1_.x / 80));
if(!changed)
{
_loc1_.timeIn += _loc3_;
}
else
{
_loc1_.timeIn = 0;
}
if(distX < 48)
{
switch(sNext)
{
case "stairsdown":
_loc1_.keyDown = true;
goNext = true;
break;
case "stairsup":
_loc1_.keyUp = true;
goNext = true;
break;
case "door":
_loc1_.keyUp = true;
goNext = true;
break;
case undefined:
case null:
_loc1_.keyRight = _loc0_ = false;
_loc1_.keyLeft = _loc0_;
_loc1_.keyDown = _loc0_;
_loc1_.keyUp = _loc0_;
_loc1_.findNewPath();
}
}
else
{
_loc1_.keyDown = _loc0_ = false;
_loc1_.keyUp = _loc0_;
}
}
if(_loc1_.timeIn > 0.25)
{
_loc1_.findNewPath();
_loc1_.timeIn = 0;
}
_loc1_.moveCharacter(_loc3_,_loc1_.keyLeft,_loc1_.keyUp,_loc1_.keyRight,_loc1_.keyDown);
if((_loc1_.layer == 1 || _loc1_.state != 0) && goNext)
{
_loc1_.keyDown = _loc0_ = false;
_loc1_.keyUp = _loc0_;
_loc1_.path.shift();
}
}
}
};
MainCharClass.prototype = new MCP.GenericObject("mainChar");
MainCharClass.prototype.update = function(fElapsed)
{
if(this.state == 0)
{
this.moveCharacter(fElapsed,Key.isDown(37),Key.isDown(38),Key.isDown(39),Key.isDown(40));
}
};